/*
============================================================================
FileName	:	XQChatRoster.h
Author		:	liyake
Website		:	http://www.liyake.com
Create Data	:	2012-03-14 16:27
Change Data	:	2012-03-14 16:27
Detail		:	just like a struct
============================================================================
*/

#ifndef _XQCHAT_ROSTER_ITEM_MODEL_H_
#define _XQCHAT_ROSTER_ITEM_MODEL_H_

#include <QStandardItemModel>
#include "XQChatRosterItem.h"
#include "QXmppRosterManager.h"
#include "QXmppPresence.h"

class CXQChatRosterItemModel : public QStandardItemModel
{
public:
	CXQChatRosterItemModel(QObject* parent);
	CXQChatRosterItem* getRosterItemFromBareJid(const QString& bareJid);

	void updatePresence(const QString& bareJid, const QMap<QString, QXmppPresence>& presences);
	void updateRoster(CXQChatRoster* pRoster);
	void updateAvatar(const QString& bareJid, const QImage& image);
	void updateName(const QString& bareJid, const QString& name);

	void removeRosterEntry(const QString& bareJid);

	void clear();

private:
    QMap<QString, CXQChatRosterItem*> m_jidRosterItemMap;
    void addRosterItemIfDontExist(const QString& fullJid);
};

#endif // _XQCHAT_ROSTER_ITEM_MODEL_H_
